package com.edu.exam.enums;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 解决方案状态枚举
 * 
 * @author S-01 Module Designer
 * @version 2.0
 * @since 2025-11-10
 */
public enum SolutionStatus implements BaseEnum {
    PENDING("pending", "待处理"),
    IN_PROGRESS("in_progress", "处理中"),
    COMPLETED("completed", "已成"),
    FAILED("failed", "失败"),
    CANCELLED("cancelled", "已消"),
    APPROVED("approved", "已批准"),
    REJECTED("rejected", "已拒绝"),
    IMPLEMENTED("implemented", "已施施"),
    VERIFIED("verified", "已验证"),
    ACTIVE("active", "激活"),
    INACTIVE("inactive", "未激活"),
    ARCHIVED("archived", "已归档"),
    DEPRECATED("deprecated", "已弃用"),
    SUSPENDED("suspended", "已暂停"),
    DEFERRED("deferred", "已延迟"),
    EXPIRED("expired", "已过期"),
    PARTIAL("partial", "部分完成"),
    FULL("full", "完全完成"),
    TEMPORARY("temporary", "临时"),
    PERMANENT("permanent", "永久"),
    AUTO("auto", "自动"),
    MANUAL("manual", "手动"),
    SYSTEM("system", "系统"),
    USER("user", "用户"),
    ADMIN("admin", "管理员");

    private final String code;
    private final String description;

    SolutionStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    /**
     * 根据代码查找查枚举值
     *
     * @param code 枚举代码
     * @return 对应的枚举值
     * @throws IllegalArgumentException 如果代码不存在
     */
    public static SolutionStatus fromCode(String code) {
        for (SolutionStatus status : SolutionStatus.values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown solution status code: " + code);
    }

    /**
     * 根据描述查找查枚举值
     *
     * @param description 枚举描述
     * @return 对应的枚举值
     * @throws IllegalArgumentException 如描述不存在
     */
    public static SolutionStatus fromDescription(String description) {
        for (SolutionStatus status : SolutionStatus.values()) {
            if (status.description.equals(description)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown solution status description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}